package com.shen.shenproject.okhttp

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.shen.shenproject.R
import okhttp3.Callback
import okhttp3.OkHttpClient
import okhttp3.Request
import java.io.IOException

/**
 * Retrofit
 */
class OkHttpActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_coroutine)

        getDataOnLine()
    }


    /**
     * OkHttp
     */
    private fun getDataOnLine(){
        val client = OkHttpClient()
        client.newCall(Request.Builder()
            .url("http://api.github.com/users/rengwuxian/repo")
            .build())
            .enqueue(object : Callback {
                override fun onFailure(call: okhttp3.Call, e: IOException) {

                }

                override fun onResponse(call: okhttp3.Call, response: okhttp3.Response) {

                }

            })
    }

}
